from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver =webdriver.Chrome()
driver.get("http://i.qq.com/")
driver.switch_to.frame('login_frame')
driver.find_element_by_link_text('帐号密码登录').click()
driver.find_element_by_id('u').send_keys('397722599')
driver.find_element_by_id('p').send_keys('liangchao!@#$123')
driver.find_element_by_id('login_button').click()
WebDriverWait(driver,10).until(EC.presence_of_all_elements_located)
ActionChains(driver).move_to_element(driver.find_element_by_id('aMainPage')).perform()
driver.find_element_by_link_text('相册').click()
driver.switch_to.frame('tphoto')
driver.find_element_by_link_text('上传照片').click()
WebDriverWait(driver,10).until(EC.presence_of_all_elements_located)
driver.switch_to.frame('photoUploadDialog')
#driver.find_element_by_link_text('选择照片').click()
ActionChains(driver).move_by_offset()
driver.switch_to_frame()